<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="script/prototype.js"></script>
<script type="text/javascript"  src="script/common.js"></script>
<link href="../style/alternative.css" media="all" rel="stylesheet" />
<style type="text/css">
#userForm {
    padding-left:2em;
    padding-top:2em;
}

#userTab td {
    border:1px solid #CCC;
}

.cellTitle{
    padding:.5em;
    text-align:right
}
</style>
<SCRIPT LANGUAGE="JavaScript">
function checkForm() {
    if($F("userName")=="") {
        alert("请输入用户名");
        return false;
    }
    if($F("password")!=$F("newPassword")) {
        alert("请检查密码");
        return false;
    }  
    return true;
    
} 
</script>
</head>
<body>

<c:choose>
<c:when test="${empty user}">
<c:set var="handler" value="user.htm?method=create" />
</c:when>
<c:otherwise>
<c:set var="handler" value="user.htm?method=update" />
</c:otherwise>
</c:choose>

<div id="content">
    <div id="content_inner">
<form name="userForm" id="userForm" action="${handler}"  method="post" onsubmit= " return checkForm()">
  <TABLE id="userTab" class="its">
  <thead>
  <TR>
    <TH colspan="2" align="center">用 户</TH>
  </TR></thead>
  <TR>
    <TD class="cellTitle">用户名: </TD>
    <TD>
<INPUT TYPE="text" NAME="userName" id="userName" value="${user.userName}" size="30">
</TD>
  </TR>
  <TR>
    <TD class="cellTitle">密 码:</TD>
    <TD>
<INPUT TYPE="password" NAME="password" id="password" size="30">
</TD>
  </TR>
<TR>
    <TD class="cellTitle">重新输入密码:</TD>
    <TD>
<INPUT TYPE="password" NAME="newPassword" id="newPassword" size="30">
</TD>
  </TR>
  <TR>
    <TD class="cellTitle">电子邮件:</TD>
    <TD>
<INPUT TYPE="text" NAME="email" id="email" value="${user.email}" size="30">
</TD>
  </TR>
  <TR>
    <TD class="cellTitle">电话号码: </TD>
    <TD>
<INPUT TYPE="text" NAME="phoneNumber" id="phoneNumber" value="${user.phoneNumber}" size="30">

</TD>
  </TR>
  <TR>
    <TD class="cellTitle">角色: </TD>
    <TD>
<SELECT NAME="roleID">
<c:forEach items="${roleList}" var="role" varStatus="roleNum">
<OPTION VALUE="${role.roleID}"
<c:if test="${user.roleID eq role.roleID }">
 selected="true"
</c:if>
>${role.roleName}</OPTION>
</c:forEach>
</SELECT>
</TD>
  </TR>
<TR>
    <TD colspan="2" align="center" class="title">
    <INPUT name="action" TYPE="hidden" value="insert">
    <INPUT name="userID" TYPE="hidden" value="${user.userID}">
    <INPUT TYPE="submit" value="保存">
    &nbsp;&nbsp;
    <INPUT TYPE="button" value="返回" onclick="javascript:history.back();"></TD>
</TR>
  </TABLE>
</form>
</div></div>
</body>
</html>
